<div class="fm-content">
  <!-- 最上面标题栏 -->
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;导入配置
  </div>
  <!-- 内容 -->
  <div class="work">

    <!-- 查询框 -->
    <div class="top">
      <!-- -->
      <input nz-input placeholder="配置名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['name:like']" />
      <nz-select [(ngModel)]="fs.queryObject['repetitionStrategy']" class="fm-input"
        (nzOpenChange)="repetitionStrategyDic.load('0')" [nzPlaceHolder]="'数据重复策略'">
        <nz-option *ngFor="let option of repetitionStrategyDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
        </nz-option>
        <nz-option *ngIf="repetitionStrategyDic.isLoading" nzDisabled nzCustomContent>
          <i nz-icon type="loading" class="loading-icon"></i>加载中...
        </nz-option>
      </nz-select>
      <nz-button-group>
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
          <button nz-button (click)="fs.editRow()">编辑</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <!-- 右则样表单主体 -->
    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
          [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
          [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
          (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead>
            <tr>
              <th nzWidth="80px" nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)"></th>
              <th>配置名称</th>
              <th nzWidth="20%">数据重复策略</th>
              <th nzWidth="20%">数据检查类型</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td><span (click)="fs.editRow(data)" class="form-edit">{{data.name}}</span></td>
              <td>{{data.repetitionStrategyName}}</td>
              <td>{{data.checkTypeName}}</td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='1300' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">配置名称</nz-form-label>
              <nz-form-control class="form-control">
                <input nz-input [(ngModel)]="fs.er.name" name="name" required #name="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">配置编号</nz-form-label>
              <nz-form-control class="form-control">
                <input nz-input [(ngModel)]="fs.er.id" name="id" required #id="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">数据重复策略</nz-form-label>
              <nz-form-control class="form-control">
                <nz-select class="form-control" [(ngModel)]="fs.er.repetitionStrategy" name="repetitionStrategy"
                  required #repetitionStrategy="ngModel" (nzOpenChange)="repetitionStrategyDic.load('0')"
                  [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of repetitionStrategyDic.datas" [nzLabel]="option.display"
                    [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="repetitionStrategyDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!repetitionStrategyDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.repetitionStrategyName" [nzValue]="fs.er.repetitionStrategy">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">数据检查类型</nz-form-label>
              <nz-form-control class="form-control">
                <nz-select class="form-control" [(ngModel)]="fs.er.checkType" name="checkType" #checkType="ngModel"
                  (nzOpenChange)="checkTypeDic.load('0')" [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of checkTypeDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="checkTypeDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!checkTypeDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.checkTypeName" [nzValue]="fs.er.checkType">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">列配置</nz-form-label>
              <nz-form-control class="form-control4">
                <nz-table [nzData]="[{}]" [nzShowPagination]='false'>
                  <thead>
                    <tr>
                      <th nzWidth="6%">列</th>
                      <th nzWidth="15%">字段名</th>
                      <th nzWidth="15%">别名</th>
                      <th nzWidth="10%">类型</th>
                      <th nzWidth="6%">主键</th>
                      <th nzWidth="6%">为空</th>
                      <th nzWidth="6%">长度</th>
                      <th nzWidth="6%">精度</th>
                      <th nzWidth="14%">字典域</th>
                      <th nzWidth="6%">值域</th>
                      <th nzWidth="10%">
                        <span class="form-edit" (click)="fs.addLocalRow(fs.er, 'items', ['id'])">
                          <添加>
                        </span>
                      </th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr *ngFor="let c of fs.er.items">
                      <td>
                        <nz-input-number [(ngModel)]="c.order" [ngModelOptions]="{standalone: true}" [nzMin]="0"
                          [nzMax]="1000" [nzStep]="1">
                        </nz-input-number>
                      </td>
                      <td>
                        <input type="text" nz-input [(ngModel)]="c.name" [ngModelOptions]="{standalone: true}" />
                      </td>
                      <td>
                        <input type="text" nz-input [(ngModel)]="c.aliasName" [ngModelOptions]="{standalone: true}" />
                      </td>
                      <td>
                        <nz-select [(ngModel)]="c.dataType" [ngModelOptions]="{standalone: true}"
                          [nzPlaceHolder]="'请选择'">
                          <nz-option *ngFor="let option of dataTypeDic.datas" [nzLabel]="option.display"
                            [nzValue]="option.id">
                          </nz-option>
                          <nz-option *ngIf="dataTypeDic.isLoading" nzDisabled nzCustomContent>
                            <i nz-icon type="loading" class="loading-icon"></i>加载中...
                          </nz-option>
                        </nz-select>
                      </td>
                      <td>
                        <label nz-checkbox [(ngModel)]="c.key" [ngModelOptions]="{standalone: true}"></label>
                      </td>
                      <td>
                        <label nz-checkbox [(ngModel)]="c.allowNull" [ngModelOptions]="{standalone: true}"></label>
                      </td>
                      <td>
                        <nz-input-number [(ngModel)]="c.maxlen" [ngModelOptions]="{standalone: true}" [nzMin]="1"
                          [nzMax]="1000" [nzStep]="1">
                        </nz-input-number>
                      </td>
                      <td>
                        <nz-input-number [(ngModel)]="c.decimaldigits" [ngModelOptions]="{standalone: true}" [nzMin]="1"
                          [nzMax]="10" [nzStep]="1">
                        </nz-input-number>
                      </td>
                      <td>
                        <input type="text" nz-input [(ngModel)]="c.dictionaryName"
                          [ngModelOptions]="{standalone: true}" />
                      </td>
                      <td>
                        <label nz-checkbox [(ngModel)]="c.dicid" [ngModelOptions]="{standalone: true}"></label>
                      </td>
                      <td>
                        <span class="form-edit" nz-popconfirm nzTitle="确认删除选择项?"
                          (nzOnConfirm)="fs.delLocalRow(fs.er.items, c)" nzPlacement="bottomRight">删除</span>
                      </td>
                    </tr>
                  </tbody>
                </nz-table>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary" [disabled]='name.invalid || id.invalid || repetitionStrategy.invalid'
              (click)="fs.save()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>
